/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package prim;

import edu.uci.ics.jung.algorithms.layout.Layout;
import edu.uci.ics.jung.algorithms.layout.StaticLayout;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.SparseMultigraph;
import org.apache.commons.collections15.Factory;

/**
 *
 * @author lulzgotskill
 */
public class GraphBuilder {
    
    private static volatile GraphBuilder m_instance;
    private Graph<String, Integer> m_graph;
    private int m_nodeCount;
    private int m_edgeCount;
    private Factory<String> m_vertexFactory;
    private Factory<Integer> m_edgeFactory;
    
    public static GraphBuilder getInstance() {
        GraphBuilder localInstance = m_instance;
        if (null == localInstance) {
            synchronized (GraphBuilder.class) {
                localInstance = m_instance;
                if (localInstance == null) {
                    m_instance = localInstance = new GraphBuilder();
                }
            }
        }
        return localInstance;
    }
    
    private GraphBuilder() {
        m_graph = new SparseMultigraph<String, Integer>();
        m_nodeCount = 0;
        m_edgeCount = 0;
        m_vertexFactory = new Factory<String>() {
            public String create() {
                return "V" + m_nodeCount++;
            }
        };
        m_edgeFactory = new Factory<Integer>() {
            public Integer create() {
                return m_edgeCount++;
            }
        };
    }
    
    public void clearGraph() {
        m_graph = new SparseMultigraph<String, Integer>();
    }
    
    public void randomize() {
        
    }

    /**
     * @return the m_graph
     */
    public Graph<String, Integer> getGraph() {
        return m_graph;
    }

    /**
     * @return the m_nodeCount
     */
    public int getNodeCount() {
        return m_nodeCount;
    }

    /**
     * @return the m_edgeCount
     */
    public int getEdgeCount() {
        return m_edgeCount;
    }

    /**
     * @return the m_vertexFactory
     */
    public Factory<String> getVertexFactory() {
        return m_vertexFactory;
    }

    /**
     * @return the m_edgeFactory
     */
    public Factory<Integer> getEdgeFactory() {
        return m_edgeFactory;
    }
}
